Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Detach InjectViewModelListener before forwarding. #258

Closed

Conversation

demiankatz
Copy link
Contributor

A long time ago, this commit was introduced to the Forward plugin: zendframework/zendframework@0b8fc7a. This prevents a problem where forwarding causes multiple InjectViewModelListeners to get attached, which in turn causes the view template to get rendered multiple times. This is a waste of cycles, and in some cases causes malfunctions (in situations where rendering a template has side effects).

It appears that somewhere along the line, this functionality was broken and the test intended to cover it was removed. This PR restores the broken functionality and adds a test to help catch future regressions.

Real life use case: my application has a "flash messages" view helper which checks the session for pending messages, displays them, and then clears the queue from the session. This bug prevents flash messages from displaying whenever the application performs a forward action, since the first render clears the queue, then the second render overwrites the first with no flash message data. For me, this is a critical bug.

Please let me know if there are any questions or if I can help to further refine this code. Thank you!

- Prevents duplicate template rendering.
@demiankatz
Copy link
Contributor Author

demiankatz commented Nov 13, 2017

Note that the failing Travis tests here do not appear to be directly related to my changes. (It looks like some middleware-related dependency may have released a new version that removes an interface and breaks some tests).

@Xerkus
Copy link
Member

Xerkus commented Nov 17, 2017

I wonder who was that idiot who reviewed that change and allowed it to pass.

In my defence it was a big PR and there were no tests for detaching listeners when I merged it.

@Xerkus
Copy link
Member

Xerkus commented Nov 17, 2017

Duplicate of #247

@Xerkus Xerkus marked this as a duplicate of #247 Nov 17, 2017
@Xerkus Xerkus closed this Nov 17, 2017
@demiankatz
Copy link
Contributor Author

Thanks for sorting it out! :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants